#include "player.h"

Player::Player()
    : m_pMediaPlayer(nullptr)
{


}

void Player::Init()
{
    m_pMediaPlayer = new QMediaPlayer();
    m_pMediaPlayer->setVolume(80);
}

void Player::DeInit()
{
    if(m_pMediaPlayer)
    {
        delete m_pMediaPlayer;
        m_pMediaPlayer = nullptr;
    }
}

bool Player::Play(QString path)
{
    if(m_pMediaPlayer)
    {
        m_pMediaPlayer->setMedia(QUrl::fromLocalFile(path));
        m_pMediaPlayer->play();
        return true;
    }
    return false;
}

